package edu.purdue.cs.ds.vss;

import java.io.Serializable;
import java.math.BigInteger;
import java.util.ArrayList;

public class VerifiableShare implements Serializable{
	
	/**
	 * For the compiler
	 */
	private static final long serialVersionUID = 8571097103219329128L;
	private byte[] EncS;
	private byte[] EncR;
	private ArrayList<BigInteger> a;
	private BigInteger a0;
	private byte[] aesRaw;
	private Share share;
	
	public VerifiableShare(Share s, 
			ArrayList<BigInteger> aval, BigInteger a0val, int indexp, ParentIndex pip, byte[] keyRaw){
		
		share = s;
		a = aval;
		a0 = a0val;
		aesRaw = keyRaw;
	}
	
	public VerifiableShare(BigInteger rval, 
			ArrayList<BigInteger> aval, BigInteger a0val, Share s, byte[] keyRaw){
		
		share = s;
		s.setR(rval);
		a = aval;
		a0 = a0val;
		aesRaw = keyRaw;
	}
	
	public BigInteger getS(){
		return share.getS();
	}
	
	public void setS(BigInteger spar){
		share.setS(spar);
	}
	
	public void setR(BigInteger rpar){
		share.setR(rpar);
	}
	
	public BigInteger getR(){
		return share.getR();
	}
	
	public ArrayList<BigInteger> getA(){
		return a;
	}
	
	public BigInteger getA0(){
		return a0;
	}
	
	public String toString(){
		return "Share:\nS: " + share.getS() + "\nR: " + share.getR() + "\nA: " + a + "\nA0: " + a0;
	}
	
	public boolean verifyShare() {
		
		return a.get(share.getIndex()+1).equals(Generator.pedersenCommit(share.getS(), share.getR()));
	}

	public int getIndex(){
		return share.getIndex();
	}

	public byte[] getEncS() {
		return EncS;
	}



	public void setEncS(byte[] encS) {
		EncS = encS;
	}



	public byte[] getEncR() {
		return EncR;
	}

	public byte[] getAesRaw(){
		return aesRaw;
	}

	public void setEncR(byte[] encR) {
		EncR = encR;
	}
	
	public void setShare(Share s){
		share = s;
	}
	
	public Share getShare(){
		return share;
	}
}
